package com.sensoro.factoryconfig.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.sensoro.factoryconfig.R;
import com.sensoro.factoryconfig.constans.Constans;

public class ManualConfigActivity extends Activity implements OnClickListener {
	private EditText textViewMac;
	private EditText textViewMajor;
	private EditText textViewMinor;
	private EditText textViewPasswd;
	private Button buttonCommit;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_manual_config);
		initLayout();
		super.onCreate(savedInstanceState);
	}

	private void initLayout() {
		textViewMac = (EditText) findViewById(R.id.textview_mac);
		textViewMajor = (EditText) findViewById(R.id.textview_major);
		textViewMinor = (EditText) findViewById(R.id.textview_minor);
		textViewPasswd = (EditText) findViewById(R.id.textview_passwd);
		buttonCommit = (Button) findViewById(R.id.button_manual_commit);
		buttonCommit.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.button_manual_commit:
			if (TextUtils.isEmpty(textViewMac.getText())
					|| TextUtils.isEmpty(textViewMajor.getText())
					|| TextUtils.isEmpty(textViewMinor.getText())
					|| TextUtils.isEmpty(textViewPasswd.getText())) {
				Toast.makeText(ManualConfigActivity.this,
						getResources().getString(R.string.manual_hint),
						Toast.LENGTH_LONG).show();
			} else {
				Intent intent = new Intent(ManualConfigActivity.this,
						ScanHardwareActivity.class);
				intent.putExtra(Constans.MAC, textViewMac.getText().toString());
				intent.putExtra(Constans.MAJOR, textViewMajor.getText()
						.toString());
				intent.putExtra(Constans.MINOR, textViewMinor.getText()
						.toString());
				intent.putExtra(Constans.PASSWD, textViewPasswd.getText()
						.toString());
				startActivity(intent);
			}
			break;

		default:
			break;
		}

	}
}
